/*
 * FleetApp JTK
 * 
 * Copyright (c) 2010, CodeRight
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice and this list of conditions.
 *   - Redistributions in binary form must reproduce the above
 *     copyright notice and this list of conditions in the 
 *     documentation and/or other materials provided with the 
 *     distribution.
 * 
 * Jazz Desktop Application Framework
 * http://jazz.coderight.nl
 * 
 * Author: Kabeh
 */
package jtk.project4.fleet.ibatis.dao;

import java.io.IOException;
import java.io.Reader;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public abstract class IbatisDao {
	public static final String CONFIG = "jtk/project4/fleet/ibatis/SqlMapConfig.xml";
	
	private static SqlMapClient sqlMap;
	
	public IbatisDao() {
		if (sqlMap == null) {
			try {
				Reader reader = Resources.getResourceAsReader(CONFIG);
				sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
			} catch (IOException ioe) {
				ioe.printStackTrace();
			}
		}
	}
	
	protected SqlMapClient getSqlMap() {
		return sqlMap;
	}
}